﻿using AutoCommunication.Base;
using AutoCommunication.Enums;
using AutoCommunication.Helper;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace AutoCommunication.Clients
{
    public class ModbusTcpClient:IDevice
    {
        #region 事件

        public event Action<BaseVariable, AlarmEventArgs> AlarmEvent;
        public event Action<IDevice> ConnectedEvent;
        public event Action<BaseVariable> DataChangeEvent;
        public event Action<BaseVariable> CycleReadEvent;
        public event Action<IDevice> DisConnectEvent;

        #endregion 事件

        #region 属性
        [Add]
        public bool IsPlcAddress { get; set; }

        public int BufferSize { get; set; }
        public bool Connected { get; set; }
        public TimeSpan CycleTime { get; set; }
        public string DevDescription { get; set; }
        public string DevName { get; set; }
        public string FullName { get; set; }
        public EndianFormat Format { get; set; }
        public bool IsActive { get; set; }
        public bool IsFirstConnect { get; set; }
        public bool IsRuning { get; set; }
        public int MaxErrorCountIsDisconnect { get; set; }
        public int MaxReadBits { get; set; }
        public int ReConnectWaitTime { get; set; }
        public int Timeout { get; set; }
        public List<GroupBase> Groups { get; set; }
        public List<Variable> Variables { get; set; }
        public CancellationTokenSource CancleToken { get; set; }

        #endregion 属性

        #region Public 方法

        public Result Init1()
        {
            throw new NotImplementedException();
        }

        public Result Init2()
        {
            throw new NotImplementedException();
        }

        public Result Connect()
        {
            throw new NotImplementedException();
        }

        public Result DisConnect()
        {
            throw new NotImplementedException();
        }

        public Result Start()
        {
            throw new NotImplementedException();
        }

        public Result Stop()
        {
            throw new NotImplementedException();
        }

        public Result Pause()
        {
            throw new NotImplementedException();
        }

        public Task<Result> WriteAsync(string name, double value)
        {
            throw new NotImplementedException();
        }

        public Result SaveJson(string path = "setting.json")
        {
            throw new NotImplementedException();
        }

        #endregion Public 方法
    }
}
